<?php
declare (strict_types=1);

namespace app\shop\model\order;

use app\admin\model\shop\order\OrderAddress;
use app\shop\model\BaseModel;
use app\shop\model\delivery\DeliveryCompanyModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

class OrderDeliveryModel extends BaseModel
{
    /**
     * @var string
     */
    protected $name = 'shop_order_delivery';

    /**
     * 关联订单详情
     * @noinspection PhpUnused
     */
    public function orderDetail(): BelongsTo
    {
        return $this->belongsTo(OrderDetailModel::class, 'order_detail_id', 'id');
    }


    /**
     * 关联订单地址
     * @return BelongsTo
     * @noinspection PhpUnused
     */
    public function orderAddress(): BelongsTo
    {
        return $this->belongsTo(OrderAddress::class, 'order_id', 'order_id');
    }

    /**
     * 关联订单
     * @return BelongsTo
     * @noinspection PhpUnused
     */
    public function orderRelation(): BelongsTo
    {
        return $this->belongsTo(OrderModel::class, 'order_id', 'id');
    }

    /**
     * 关联物流公司
     * @return BelongsTo
     * @noinspection PhpUnused
     */
    public function deliveryCompany(): BelongsTo
    {
        return $this->belongsTo(DeliveryCompanyModel::class, 'delivery_company_id', 'id');
    }

    /**
     * 关联发货详情
     * @return HasMany
     */
    public function detail(): HasMany
    {
        return $this->hasMany(OrderDeliveryDetailModel::class, 'delivery_id', 'id');
    }
}
